package com.haimi.shiguang.utils;

import io.reactivex.Observable;
import io.reactivex.subjects.PublishSubject;

/**
 * Description:
 * Creator:zhou.junyou@puscene.com
 * Create by:Android Studio
 * Date:2017/5/4
 */
public class Rx2Bus {
    private static final String TAG = "Rx2Bus";

    private static volatile Rx2Bus sInstance;

    public static Rx2Bus getInstance() {
        if (sInstance == null) {
            synchronized (Rx2Bus.class) {
                if (sInstance == null) {
                    sInstance = new Rx2Bus();
                }
            }
        }
        return sInstance;
    }

    private PublishSubject<Object> mEventBus = PublishSubject.create();


    public void post(Object event) {
        mEventBus.onNext(event);
    }


    public Observable<Object> toObservable() {
        return mEventBus;
    }

}
